<?php

namespace Acme\FileManagerBundle\Entity;

abstract class BaseFile
{
    protected $m_name;
    protected $m_permissions = false;
    protected $m_path;
    protected $m_relativePath;
    
    public function setName($name)
    {
        $this->m_name = $name;
    }
    
    public function getName()
    {
        return $this->m_name;
    }
    
    public function setRelativePath($path)
    {
        $this->m_relativePath = $path;
    }
    
    public function getRelativePath()
    {
        return $this->m_relativePath;
    }
    
    public function getSlug()
    {
        return $this->getRelativePath();
    }
    
    public function setPermissions($permissions)
    {
        $this->m_permissions = $permissions;
    }
    
    public function getPermissions()
    {
        if (!$this->m_permissions)
        {
            // $this->m_permissions = \substr(\sprintf('%o', \fileperms($this->m_path)), -4);
            $this->m_permissions = \substr(\decoct(\fileperms($this->m_path)), -4);
        }
        
        return $this->m_permissions;
    }
    
    public function getSize()
    {
        return \filesize($this->m_path);
    }
    
    public function setPath($path)
    {
        $this->m_path = $path;
    }
    
    public function getPath()
    {
        return $this->m_path;
    }
}